﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <!-- TODO: Drop Shadows... rethink using DropShadowEffect since it might interfere with other shaders -->
    
    <!-- Brushes -->
    <SolidColorBrush x:Key="MenuItemBackgroundBrush" Color="#FF3A3A3A" />
    <SolidColorBrush x:Key="MenuItemHoverBrush" />
    <SolidColorBrush x:Key="MenuItemTextBrush" Color="#FFF0F0F0" />
    <SolidColorBrush x:Key="MenuItemDisabledTextBrush" Color="#FF666666" />
    <SolidColorBrush x:Key="MenuItemHoveredTextBrush" Color="#FF333333" />
    <SolidColorBrush x:Key="MenuItemHoveredBackgroundBrush" Color="#FFAAAAAA" />
    <SolidColorBrush x:Key="MenuItemBorderBrush" Color="#FF595959" />
    
    <!-- Separator -->
    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin" Value="3,2,3,2" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Border Background="#FF4C4C4C" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Menu (Bar) -->
    <Style TargetType="{x:Type Menu}">
        <Setter Property="Background" Value="{StaticResource MenuItemBackgroundBrush}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <StackPanel Background="{TemplateBinding Background}" IsItemsHost="True" ClipToBounds="True" Orientation="Horizontal" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- MenuItem -->
    <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Background" Value="{StaticResource MenuItemBackgroundBrush}" />
        <Setter Property="Foreground" Value="{StaticResource MenuItemTextBrush}" />
        <Setter Property="FontSize" Value="11" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid Name="Grid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
                                <ColumnDefinition Width="14" />
                            </Grid.ColumnDefinitions>
                            <Path Name="GlyphPanel" Visibility="Hidden" Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Data="F0 M 0,2 L 0,4.8 2.5,7.4 7.1,2.8 7.1,0 2.5,4.6 Z" FlowDirection="LeftToRight" />
                            <ContentPresenter Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="1" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentSource="Header" />
                            <TextBlock Name="InputGestureText" Margin="5,2,0,2" Grid.Column="2" DockPanel.Dock="Right" Text="{TemplateBinding InputGestureText}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Setter Value="{StaticResource MenuItemHoveredBackgroundBrush}" Property="Background" />
                            <Setter Value="{StaticResource MenuItemHoveredTextBrush}" Property="Foreground" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Value="{StaticResource MenuItemDisabledTextBrush}" Property="Foreground" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Margin" Value="0,1,0,1" />
                <Setter Property="Padding" Value="6,3,6,3" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type MenuItem}">
                            <Border Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <DockPanel Name="DockPanel">
                                    <Path Name="GlyphPanel" Visibility="Collapsed" Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Data="F0 M 0,2 L 0,4.8 2.5,7.4 7.1,2.8 7.1,0 2.5,4.6 Z" FlowDirection="LeftToRight" />
                                    <ContentPresenter Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentSource="Header" />
                                    <Popup Name="PART_Popup" AllowsTransparency="True" Placement="Bottom" Focusable="False" IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}">
                                        <Border Name="SubMenuBorder" Background="{StaticResource MenuItemBackgroundBrush}" BorderThickness="1,1,1,1" BorderBrush="{StaticResource MenuItemBorderBrush}">
                                            <ScrollViewer Name="ScrollViewer" CanContentScroll="True" Style="{StaticResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                                                <ItemsPresenter Name="ItemsPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,2,2,2" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" Grid.IsSharedSizeScope="True" />
                                            </ScrollViewer>
                                        </Border>
                                    </Popup>
                                </DockPanel>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
                                </Trigger>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter Value="{StaticResource MenuItemHoveredBackgroundBrush}" Property="Background" />
                                    <Setter Value="{StaticResource MenuItemHoveredTextBrush}" Property="Foreground" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Value="{StaticResource MenuItemDisabledTextBrush}" Property="Foreground" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Margin" Value="0,1,0,1" />
                <Setter Property="Padding" Value="6,3,6,3" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type MenuItem}">
                            <Border Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <DockPanel Name="DockPanel">
                                    <Path Name="GlyphPanel" Visibility="Collapsed" Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Data="F0 M 0,2 L 0,4.8 2.5,7.4 7.1,2.8 7.1,0 2.5,4.6 Z" FlowDirection="LeftToRight" />
                                    <ContentPresenter Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentSource="Header" />
                                </DockPanel>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
                                </Trigger>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter Value="{StaticResource MenuItemHoveredBackgroundBrush}" Property="Background" />
                                    <Setter Value="{StaticResource MenuItemHoveredTextBrush}" Property="Foreground" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Value="{StaticResource MenuItemDisabledTextBrush}" Property="Foreground" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="DockPanel.Dock" Value="Top" />
                <Setter Property="Padding" Value="0,2,0,2" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type MenuItem}">
                            <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid Name="Grid">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
                                        <ColumnDefinition Width="14" />
                                    </Grid.ColumnDefinitions>
                                    <Path Name="GlyphPanel" Visibility="Hidden" Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Data="F0 M 0,2 L 0,4.8 2.5,7.4 7.1,2.8 7.1,0 2.5,4.6 Z" FlowDirection="LeftToRight" />
                                    <ContentPresenter Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="1" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentSource="Header" />
                                    <Path Name="Path" Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Grid.Column="3" DockPanel.Dock="Right" Data="F0 M 0,0 L 4,3.5 0,7 Z" />
                                    <Popup Name="PART_Popup" AllowsTransparency="True" Placement="Right" Focusable="False" VerticalOffset="-1" HorizontalOffset="1" IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}">
                                        <Border Name="SubMenuBorder" BorderThickness="1,1,1,1" Background="{StaticResource MenuItemBackgroundBrush}" BorderBrush="{StaticResource MenuItemBorderBrush}">
                                            <ScrollViewer Name="ScrollViewer" CanContentScroll="True" Style="{StaticResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                                                <ItemsPresenter Name="ItemsPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,2,2,2" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" Grid.IsSharedSizeScope="True" />
                                            </ScrollViewer>
                                        </Border>
                                    </Popup>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
                                </Trigger>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter Value="{StaticResource MenuItemHoveredBackgroundBrush}" Property="Background" />
                                    <Setter Value="{StaticResource MenuItemHoveredTextBrush}" Property="Foreground" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Value="{StaticResource MenuItemDisabledTextBrush}" Property="Foreground" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="DockPanel.Dock" Value="Top" />
                <Setter Property="Padding" Value="0,2,0,2" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
        <Setter Property="Background" Value="{StaticResource MenuItemBackgroundBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="{StaticResource MenuItemBorderBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer CanContentScroll="True" Style="{StaticResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
                            <ItemsPresenter Margin="{TemplateBinding Padding}" KeyboardNavigation.DirectionalNavigation="Cycle" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>